package com.example.student.Servicelmpl;

import com.example.student.Repository.CourseRepository;
import com.example.student.Service.CourseService;
import com.example.student.entity.Course;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {
    // 假设有一个CourseRepository用于数据库操作
    @Autowired
    private CourseRepository courseRepository;

    @Override
    public List<Course> listAll() {
        return courseRepository.findAll();
    }

    @Override
    public Course getById(Long courseId) {
        return courseRepository.findById(courseId).orElse(null);
    }

    @Override
    public void add(Course course) {
        courseRepository.save(course);
    }
}